package main

import (
	"fmt"
)

func main() {
	nums := []int{2, 3, 7, 9}
	target := 9
	fmt.Println(twoSum(nums, target))
}

func twoSum(nums []int, target int) []int {
	var result []int
	someMap := make(map[int]int)

	for i := 0; i < len(nums); i++ {
		if _, ok := someMap[target-nums[i]]; ok {
			result = append(result, someMap[target-nums[i]])
			result = append(result, i)
			return result
		} else {
			someMap[nums[i]] = i
		}
	}
	return result
}
